package com.tedu.activity.controller;

import com.tedu.activity.pojo.Activity;
import com.tedu.activity.service.ActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author Song
 * @since 2020/10/9
 */
@Slf4j
@Controller
@RequestMapping("/activity")

public class ActivityController {

    @Autowired
    ActivityService activityService;

    @RequestMapping("/doFindActivitys")
    @ResponseBody
    public List<Activity> doFindActivitys() {
        List<Activity>  list=activityService.findActivitys();
        log.info("==doFindActivitys====");
        return list;
    }

    @RequestMapping("/doActivityUI")
    public String doActivityUI(){
        log.info("==doActivityUI====");
        return "activity";
    }

    @RequestMapping("/doSaveActivity")
    @ResponseBody
    public String doSaveActivity(Activity activity) {
        activityService.saveActivity(activity);
        log.info("==doSaveActivity====");
        return "save ok";
    }

    @RequestMapping("/doDel")
    @ResponseBody
    public String doDel(Long id){
        activityService.deleteObject(id);
        log.info("==doDel====");
        return "delete ok";
    }

}
